package exercise;

class Solution4 {
    public int maxArea(int[] height) {
        int l = 0, r = height.length-1, ret = 0;

        while (l < r) {
            int v = Math.min(height[l], height[r]) * (r - l);
            ret = Math.max(ret, v);
            if (height[l] > height[r]) {
                r--;
            } else {
                l++;
            }
        }
        return ret;
    }
}